﻿var forgetApp = angular.module('forgetApp', []);

forgetApp.controller('ForgetController', function ($scope, $location, ForgetService) {
    $scope.send = function (user) {
        $("#spinner").show();
        $scope.error = "";
        $scope.success = "";
        ForgetService.sendLink(user).then(function () {
            $("#spinner").hide();
            $scope.error = "";
            $scope.success = "Password reset link sent.";
        }, function () {
            $("#spinner").hide();
            $scope.error = "Account not registered in R4U.";
        });
    };

    $scope.reset = function (user) {
        $("#spinner").show();
        $scope.error = "";
        $scope.success = "";
        ForgetService.resetPassword(user).then(function () {
            $("#spinner").hide();
            alert("Password successfully reset.Proceed login...");
            window.location.assign("/Login");
        }, function () {
            $("#spinner").hide();
            $scope.error = "Error occured during execution.";
        });
    };

});
